<template>
  <div ref="echart" class="echart"></div>
</template>

<script>
export default {
  data() {
    return {
      echart: null
    }
  },
  mounted() {
    this.initDta()
  },
  methods: {
    initDta() {
      this.echart = this.$echarts.init(this.$refs.echart)
      const option = {
        title: {
          text: '港区进出港船舶展示',
          bottom: '5',
          left: 'center',
          show: true,
          textStyle: {
            color: '#8FEFFF',
            fontSize: 16, // 改变标示文字的大小
            fontWeight: 'normal',
          },
        },
        tooltip: {
          trigger: 'item',
        },
        legend: {
          orient: 'vertical',
          top: 'center',
          right: '3%',
          itemGap: 20,
          textStyle: {
            color: '#FFF',
            fontSize: 16,
          },
        },
        series: [
          {
            type: 'pie',
            center: ['45%', '55%'],
            radius: ['25%', '55%'],
            avoidLabelOverlap: false,
            label: {
              show: true,
              position: 'left',
              formatter: function (data) {
               return data.value + '万吨'
              },
              color: '#8FEFFF',
              fontWeight: 'bold',
              fontSize: '14',
              padding: '10',
            },
            labelLine: {
              show: false,
            },
            data: [{
              name: '散货船',
              value: '99'
            },
              {
                name: '其他',
                value: '12'
              },
              {
                name: '危险品船',
                value: '30'
              }],
          },
        ],
      }
      this.echart.setOption(option)
    }
  }
}
</script>

<style scoped lang="less">
.echart {
  width: 100%;
  height: 100%;
}
</style>
